#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
const int N=2e5+10,M=N<<1,K=65;
inline int read()
{
    int x=0;char ch=getchar();
    while(!isdigit(ch)) ch=getchar();
    while(isdigit(ch)) x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
    return x;
}
int n,m,q,ID[K];
int first[N],to[M],nxt[M],id[M],cnt;
bool vis[N],flag[N];
ull P[K],H[N],pre[N];
mt19937_64 g(time(0));
inline void inc(int x,int y,int l) {nxt[++cnt]=first[x],to[cnt]=y,first[x]=cnt,id[cnt]=l;}
void dfs(int x)
{
    vis[x]=1;
    for(int i=first[x],v,p;i;i=nxt[i])
    {
        v=to[i],p=id[i];
        if(!vis[v]) flag[p]=1,dfs(v),H[p]=pre[v],pre[x]^=pre[v];
        else if(!flag[p])
        {
            flag[p]=1;
            while(!H[p]) H[p]=g();
            pre[x]^=H[p],pre[v]^=H[p];
        }
    }
}
bool add(ull x)
{
    for(int i=K-1;~i;i--)
    {
        if(!(x>>i&1)) continue;
        if(!P[i]) return P[i]=x;
        x^=P[i];
    }
    return 0;
}
int main()
{
    freopen("graph.in","r",stdin);
    freopen("graph.out","w",stdout);
    n=read(),m=read();
    for(int i=1,u,v;i<=m;i++)
        u=read(),v=read(),inc(u,v,i),inc(v,u,i);
    dfs(1);
    q=read();
    int k,x;
L:  while(q--)
    {
        k=read();
        for(int i=1;i<=k;i++) ID[i]=read();
        memset(P,0,sizeof(P));
        for(int i=1;i<=k;i++)
            if(!add(H[ID[i]])) {puts("NO");goto L;}
        puts("YES");
    }
    return 0;
}